/**
 * 
 */
package jnzb.ui;

import java.awt.Component;
import java.awt.Dimension;

/**
 * This class contains useful methods for manipulating Swing components.
 * 
 * @author Richard Levy
 * 
 */
public class SwingUtils {

	/**
	 * Ensure that this class cannot be instantiated.
	 */
	private SwingUtils() {
	}

	/**
	 * Set the maximum height of the component to its prefered height and leave the width as it is 
	 * @param component - the component to set the size of
	 */
	public static void fixMaximumPrefefedHeight(Component component) {
		Dimension resizer = new Dimension();
		resizer.setSize(component.getMaximumSize().getWidth(), component.getPreferredSize().getHeight());
		component.setMaximumSize(resizer);
	}

	/**
	 * Set the maximum width of the component to its prefered width and leave the width as it is
	 * @param component - the component to set the size of
	 */
	public static void fixMaximumPreferedWidth(Component component) {
		Dimension resizer = new Dimension();
		resizer.setSize(component.getPreferredSize().getWidth(), component.getMaximumSize().getHeight());
		component.setMaximumSize(resizer);
	}
}
